<template>
    <h2>用户借款还款</h2>
    借款名称:<input type="text" v-model="B_Name">
    <input type="button" @click="Show" value="查询">
    <table>
        <thead>
            <tr>
                <td>借款款项ID</td>
                <td>借款款项名称</td>
                <td>借款最高金额</td>
                <td>借款最高年限</td>
                <td>预计月还款金额</td>
                <td>利率值</td>
                <td>操作</td>
            </tr>
        </thead>
        <tbody>
            <tr v-for="item in data" :key="item.B_Id">
                <td>{{ item.B_Id }}</td>
                <td>{{ item.B_Name }}</td>
                <td>{{ item.B_Max }}</td>
                <td>{{ item.B_Year }}</td>
                <td>{{ (item.B_Max / 12).toFixed(2) }}</td>
                <td>{{ item.I_Inser }}%</td>
                <td><input type="button" @click="User(item.B_Id)" value="用户还款明细"></td>
            </tr>
        </tbody>
    </table>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import axios from 'axios';
import { useRouter } from 'vue-router';
import { onMounted } from 'vue';
const data = ref([{
    B_Id: 0,
    B_Name: '',
    B_Max: 0,
    B_Year: 0,
    I_Inser: 0
}])
const B_Name = ref('');
onMounted(() => {
    Show();
})
const Show = () => {
    axios.get('http://localhost:57910/api/Demo/Show', {
        params: {
            B_Name: B_Name.value
        }
    })
        .then(res => {
            data.value = res.data
        })
}
const router = useRouter();
const User = (B_Id: number) => {
    router.push({
        name: 'UserInfo',
        params: {
            B_Id: B_Id
        }
    })
}


</script>